<?php


namespace app\api\model;


use think\Model;

class FoodTypeModel extends Model
{

    // 表名
    protected $name = 'food_type';


    // 追加属性
    protected $append = [
        'food_list'
    ];

    public function getFoodListAttr($val,$data)
    {
        return FoodListModel::where(['type_id'=>$data['id'],'is_show'=>1])->order('weigh desc')->select();
    }

    public static function getList($type = 0){
        return Self::where(['type'=>$type,'is_show'=>1])->order('weigh desc')->select();
    }

}